Skip to content

feat: generate docs explorer site from C# and Python ports - #672

Merged
dmealing merged 24 commits into
mainfrom
fm/mo-130-docs-view-cs-py
Nov 28, 2026
Merged

dmealing merged 24 commits into
mainfrom
fm/mo-130-docs-view-cs-py

Conversation

@dmealing

@dmealing dmealing commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Validated in 1 no-mistakes run (5 review fix rounds, then test, document and lint passed).

What Changed

  • Adds a docs-site generator to the C# and Python ports. It writes explorer.json, the stamp file, the model script and the shared explorer app files, so a C# or Python project gets the docs explorer without Node. The explorer app is embedded in MetaObjects.Codegen and as package data in Python.
  • Adds DocsView modules in both ports (server/csharp/MetaObjects/DocsView/, server/python/src/metaobjects/docs_view.py) that build the port-neutral docs view in memory from the loaded model. MetaEndpoint (C#) and meta_endpoint.py (Python) serve it beside /_meta with ETag/304 support, behind the same opt-in mount.
  • Runner runs docs-site after the other generators. Manifest provenance now records generatedBy as the stable registry name (entity, filter-allowlist, routes) in both ports, matching TypeScript and Java.
Validation

Risk Assessment

✅ Low: The round-5 fix makes C# and Python treat an empty file list inside a run as a known, empty list, which matches TypeScript's runDocsView and Java; the corpus test now drives the generator outside a run with the case's committed manifest (crm/model-alone expect files:false, shop expects true), and the drift cases assert the TS-oracle value.

Testing

Baseline configured test command passed and was not re-run. Drove three live scenarios with the real Python metaobjects CLI and the real C# dotnet CLI against a disposable copy of the shop fixture: fresh gen plus verify (both ports pass, files in sync); hand-edited explorer.json refused by gen and flagged by verify (both ports fail closed as designed). Byte-identity of explorer.json against the TypeScript reference and the /_meta-style docs-view endpoint ETag/304 were not driven live here; they are covered by the corpus and endpoint tests in the baseline. Overall: pass on driven scenarios.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Python: metaobjects gen with a docs-site target writes explorer.json and site files; fresh verify --codegen --full is in sync (shop model, local CLI) ✅ pass live Python gen exit 0 (17 files); verify exit 0 '[docs]: in sync (9 file(s))'; explorer.json parses with 10 nodes; py-explorer.json artifact
Python: hand-edited explorer.json is refused by gen and flagged as drift by verify ✅ pass live gen: 'Refused to overwrite site/explorer.json'; verify exit 1 '[docs] generated code is out of sync with metadata'
C#: dotnet gen with a docs-site entry writes explorer.json; fresh verify --codegen --full is in sync (local CLI, in-repo codegen project) ✅ pass live cs-gen-fresh.txt (gen exit 0, 17 files written incl. docs/site/explorer.json); cs-verify-fresh.txt (verify exit 0)
C#: hand-edited explorer.json is refused by gen and flagged by verify ✅ pass live cs-gen-after-tamper.txt ('refused: docs/site/explorer.json', exit 1); cs-verify-after-tamper.txt ('~ docs/site/explorer.json ... differs', exit 1)
Byte-identical explorer.json for every fixtures/explorer-conformance case across C#, Python and TypeScript, served beside /_meta with ETag/304 ⏸️ untested no Tried live: comparing the C# and Python project outputs. Those differ only in per-language file names, so they are not a byte-identity oracle. The corpus expected.json is pinned by the baseline's port…
Evidence: C# fresh gen transcript
  written: acme/shop/AuditEntry.g.cs
  written: acme/shop/Customer.g.cs
  written: acme/shop/Order.g.cs
  written: acme/shop/Address.g.cs
  written: acme/shop/OrderNote.g.cs
  written: acme/shop/OrderNoteRequest.g.cs
  written: acme/shop/OrderQueries.g.cs
  written: DecimalWire.g.cs
  written: docs/site/index.html
  written: docs/site/assets/explorer-app.js
  written: docs/site/assets/cytoscape.min.js
  written: docs/site/assets/3d-force-graph.min.js
  written: docs/site/assets/explorer.css
  written: docs/site/assets/explorer.js
  written: docs/site/explorer-model.js
  written: docs/site/explorer-stamp.js
  written: docs/site/explorer.json
dotnet meta gen: 17 file(s) written
Evidence: C# fresh verify transcript
dotnet meta verify --codegen: OK (generated output is in sync)
Evidence: C# gen after hand edit (refused)
  unchanged: acme/shop/AuditEntry.g.cs
  unchanged: acme/shop/Customer.g.cs
  unchanged: acme/shop/Order.g.cs
  unchanged: acme/shop/Address.g.cs
  unchanged: acme/shop/OrderNote.g.cs
  unchanged: acme/shop/OrderNoteRequest.g.cs
  unchanged: acme/shop/OrderQueries.g.cs
  unchanged: DecimalWire.g.cs
  unchanged: docs/site/index.html
  unchanged: docs/site/assets/explorer-app.js
  unchanged: docs/site/assets/cytoscape.min.js
  unchanged: docs/site/assets/3d-force-graph.min.js
  unchanged: docs/site/assets/explorer.css
  unchanged: docs/site/assets/explorer.js
  unchanged: docs/site/explorer-model.js
  unchanged: docs/site/explorer-stamp.js
  refused: docs/site/explorer.json
  warning: Refused to overwrite docs/site/explorer.json: it has been edited since it was generated, or there is no record of generating it. Move your edits into a non-generated file, or delete it to accept fresh output.
dotnet meta gen: 0 file(s) written
dotnet meta gen: FAILED — 1 file(s) refused (see the warnings above; `--baseline=adopt` records what you have and writes nothing)
Evidence: C# verify after hand edit (drift)
dotnet meta verify --codegen: drift (1 file(s) differ from a fresh regen):
  ~ docs/site/explorer.json (committed content differs from a fresh regen)
Run 'dotnet meta gen' to regenerate (it needs --out, the same directory you gave this command), then commit the result.
Evidence: Python-generated explorer.json from shop model
{
  "format": "metaobjects-docs-view/1",
  "sources": {
    "requirements": false,
    "files": true,
    "routes": false
  },
  "counts": {
    "nodes": 10,
    "packages": 1,
    "requirements": 9,
    "functional": 8,
    "architectural": 1,
    "byStatus": [
      {
        "status": "planned",
        "count": 1
      },
      {
        "status": "live",
        "count": 7
      },
      {
        "status": "partial",
        "count": 1
      },
      {
        "status": "retired",
        "count": 0
      }
    ],
    "claims": 5,
    "files": 7,
    "routes": 0,
    "undecided": 0,
    "coverageMeasured": false,
    "entitiesClaimed": 0,
    "entitiesTotal": 0
  },
  "packages": [
    {
      "name": "acme::shop",
      "count": 10,
      "groups": [
        {
          "type": "object",
          "subType": "entity",
          "count": 4,
          "nodes": [
            {
              "label": "AuditEntry",
              "id": "acme::shop::AuditEntry",
              "path": "model/acme/shop/AuditEntry.html",
              "kind": "object.entity",
              "unresolved": false
            },
            {
              "label": "BaseEntity",
              "id": "acme::shop::BaseEntity",
              "path": "model/acme/shop/BaseEntity.html",
              "kind": "object.entity",
              "unresolved": false
            },
            {
              "label": "Customer",
              "id": "acme::shop::Customer",
              "path": "model/acme/shop/Customer.html",
              "kind": "object.entity",
              "unresolved": false
            },
            {
              "label": "Order",
              "id": "acme::shop::Order",
              "path": "model/acme/shop/Order.html",
              "kind": "object.entity",
              "unresolved": false
            }
          ]
        },
        {
          "type": "object",
          "subType": "value",
          "count": 3,
          "nodes": [
            {
              "label": "Address",
              "id": "acme::shop::Address",
              "path": "model/acme/shop/Address.html",
              "kind": "object.value",
              "unresolved": false
            },
            {
              "label": "OrderNote",
              "id": "acme::shop::OrderNote",
              "path": "model/acme/shop/OrderNote.html",
              "kind": "object.value",
              "unresolved": false
            },
            {
              "label": "OrderNoteRequest",
              "id": "acme::shop::OrderNoteRequest",
              "path": "model/acme/shop/OrderNoteRequest.html",
              "kind": "object.value",
              "unresolved": false
            }
          ]
        },
        {
          "type": "requirement",
          "subType": "architectural",
          "count": 1,
          "nodes": [
            {
              "label": "Addressable",
              "id": "acme::shop::Addressable",
              "path": "requirements/acme/shop/Addressable.html",
              "kind": "requirement.architectural",
              "unresolved": false
            }
          ]
        },
        {
          "type": "requirement",
          "subType": "functional",
          "count": 1,
          "nodes": [
            {
              "label": "Shop",
              "id": "acme::shop::Shop",
              "path": "requirements/acme/shop/Shop.html",
              "kind": "requirement.functional",
              "unresolved": false
            }
          ]
        },
        {
          "type": "template",
          "subType": "prompt",
          "count": 1,
          "nodes": [
            {
              "label": "OrderNotePrompt",
              "id": "acme::shop::OrderNotePrompt",
              "path": "model/acme/shop/OrderNotePrompt.html",
              "kind": "template.prompt",
              "unresolved": false
            }
          ]
        }
      ]
    }
  ],
  "nodes": [
    {
      "id": "acme::shop::Address",
      "name": "Address",
      "package": "acme::shop",
      "type": "object",
      "subType": "value",
      "order": 1,
      "path": "model/acme/shop/Address.html",
      "title": "",
      "description": "",
      "summary": "",
      "abstract": false,
      "extends": null,
      "attrs": [],
      "memberGroups": [
        {
          "type": "field",
          "count": 2,
          "members": [
            {
              "id": "acme::shop::Address.street",
              "name": "street",
              "type": "field",
              "subType": "string",
              "order": 0,
              "anchor": "m-street",
              "path": "model/acme/shop/Address.html#m-street",
              "abstract": false,
              "isArray": false,
              "extends": null,
              "declaredOn": null,
              "attrs": [],
              "refs": [],
              "claims": [],
              "memberGroups": []
            },
            {
              "id": "acme::shop::Address.city",
              "name": "city",
              "type": "field",
              "subType": "string",
              "order": 1,
              "anchor": "m-city",
              "path": "model/acme/shop/Address.html#m-city",
              "abstract": false,
              "isArray": false,
              "extends": null,
              "declaredOn": null,
              "attrs": [],
              "refs": [],
              "claims": [],
              "memberGroups": []
            }
          ]
        }
      ],
      "refs": [],
      "referencedBy": [
        {
          "attr": "objectRef",
          "from": {
            "label": "Customer",
            "id": "acme::shop::Customer",
            "path": "model/acme/shop/Customer.html",
            "kind": "object.entity",
            "unresolved": false
          },
          "via": {
            "label": "Customer.shippingAddress",
            "id": "acme::shop::Customer.shippingAddress",
            "path": "model/acme/shop/Customer.html#m-shippingAddress",
            "kind": "field.object",
            "unresolved": false
          },
          "target": {
            "label": "Address",
            "id": "acme::shop::Address",
            "path": "model/acme/shop/Address.html",
            "kind": "object.value",
            "unresolved": false
          }
        }
      ],
      "claims": [],
      "files": [
        {
          "generatedBy": "entity",
          "paths": [
            "generated/Address.py"
          ]
        }
      ],
      "routes": [],
      "unclaimed": false,
      "counts": {
        "members": 2,
        "refs": 0,
        "referencedBy": 1,
        "claims": 0,
        "files": 1,
        "routes": 0
      }
    },
    {
      "id": "acme::shop::Addressable",
      "name": "Addressable",
      "package": "acme::shop",
      "type": "requirement",
      "subType": "architectural",
      "order": 8,
      "path": "requirements/acme/shop/Addressable.html",
      "title": "",
      "description": "",
      "summary": "",
      "abstract": false,
      "extends": null,
      "attrs": [
        {
          "name": "counterexample",
          "value": "A row nobody can point at.",
          "values": [
            {
              "text": "A row nobody can point at.",
              "link": null
            }
          ]
        },
        {
          "name": "implementedBy",
          "value": [
            "BaseEntity"
          ],
          "values": [
            {
              "text": "BaseEntity",
              "link": null
            }
          ]
        },
        {
          "name": "statement",
          "value": "Every stored row has a stable id.",
          "values": [
            {
              "text": "Every stored row has a stable id.",
              "link": null
            }
          ]
        },
        {
          "name": "status",
          "value": "live",
          "values": [
            {
              "text": "live",
              "link": null
            }
          ]
        }
      ],
      "memberGroups": [],
      "refs": [],
      "referencedBy": [],
      "claims": [],
      "files": [],
      "routes": [],
      "unclaimed": false,
      "coun

... [81759 bytes truncated] ...

r": false,
      "verdict": "",
      "digest": "",
      "diagnostics": [],
      "rollup": [
        {
          "status": "planned",
          "count": 0
        },
        {
          "status": "live",
          "count": 1
        },
        {
          "status": "partial",
          "count": 0
        },
        {
          "status": "retired",
          "count": 0
        }
      ],
      "rollupTotal": 1,
      "belowCount": 0,
      "childCount": 0,
      "targets": [
        {
          "label": "OrderNotePrompt",
          "id": "acme::shop::OrderNotePrompt",
          "path": "model/acme/shop/OrderNotePrompt.html",
          "kind": "template.prompt",
          "unresolved": false
        }
      ],
      "targetCount": 1
    },
    {
      "id": "acme::shop::Shop.Checkout.Orders.Refunded",
      "name": "Refunded",
      "label": "Refunded",
      "path": "requirements/acme/shop/Shop.Checkout.Orders.Refunded.html",
      "address": "Shop.Checkout.Orders.Refunded",
      "package": "acme::shop",
      "qualifiedPath": "acme::shop::Shop.Checkout.Orders.Refunded",
      "subType": "functional",
      "level": 4,
      "status": "planned",
      "disposition": "",
      "statement": "A paid order can be refunded.",
      "counterexample": "A paid order that cannot be refunded.",
      "title": "",
      "description": "",
      "trackedBy": [],
      "depth": 3,
      "parent": {
        "label": "Orders",
        "id": "acme::shop::Shop.Checkout.Orders",
        "path": "requirements/acme/shop/Shop.Checkout.Orders.html",
        "kind": "requirement.functional",
        "unresolved": false
      },
      "breadcrumbs": [
        {
          "label": "Shop",
          "id": "acme::shop::Shop",
          "path": "requirements/acme/shop/Shop.html",
          "kind": "requirement.functional",
          "unresolved": false
        },
        {
          "label": "Checkout",
          "id": "acme::shop::Shop.Checkout",
          "path": "requirements/acme/shop/Shop.Checkout.html",
          "kind": "requirement.functional",
          "unresolved": false
        },
        {
          "label": "Orders",
          "id": "acme::shop::Shop.Checkout.Orders",
          "path": "requirements/acme/shop/Shop.Checkout.Orders.html",
          "kind": "requirement.functional",
          "unresolved": false
        }
      ],
      "children": [],
      "implementedBy": [
        {
          "ref": "Refund",
          "resolves": false,
          "target": {
            "label": "Refund",
            "id": "",
            "path": "",
            "kind": "",
            "unresolved": true
          }
        }
      ],
      "supersededBy": null,
      "inLedger": false,
      "verdict": "",
      "digest": "",
      "diagnostics": [],
      "rollup": [
        {
          "status": "planned",
          "count": 1
        },
        {
          "status": "live",
          "count": 0
        },
        {
          "status": "partial",
          "count": 0
        },
        {
          "status": "retired",
          "count": 0
        }
      ],
      "rollupTotal": 1,
      "belowCount": 0,
      "childCount": 0,
      "targets": [],
      "targetCount": 0
    },
    {
      "id": "acme::shop::Shop.Checkout.Shipping",
      "name": "Shipping",
      "label": "Shipping",
      "path": "requirements/acme/shop/Shop.Checkout.Shipping.html",
      "address": "Shop.Checkout.Shipping",
      "package": "acme::shop",
      "qualifiedPath": "acme::shop::Shop.Checkout.Shipping",
      "subType": "functional",
      "level": 3,
      "status": "live",
      "disposition": "",
      "statement": "A paid order is shipped.",
      "counterexample": "A paid order that never ships.",
      "title": "",
      "description": "",
      "trackedBy": [],
      "depth": 2,
      "parent": {
        "label": "Checkout",
        "id": "acme::shop::Shop.Checkout",
        "path": "requirements/acme/shop/Shop.Checkout.html",
        "kind": "requirement.functional",
        "unresolved": false
      },
      "breadcrumbs": [
        {
          "label": "Shop",
          "id": "acme::shop::Shop",
          "path": "requirements/acme/shop/Shop.html",
          "kind": "requirement.functional",
          "unresolved": false
        },
        {
          "label": "Checkout",
          "id": "acme::shop::Shop.Checkout",
          "path": "requirements/acme/shop/Shop.Checkout.html",
          "kind": "requirement.functional",
          "unresolved": false
        }
      ],
      "children": [],
      "implementedBy": [],
      "supersededBy": null,
      "inLedger": false,
      "verdict": "",
      "digest": "",
      "diagnostics": [],
      "rollup": [
        {
          "status": "planned",
          "count": 0
        },
        {
          "status": "live",
          "count": 1
        },
        {
          "status": "partial",
          "count": 0
        },
        {
          "status": "retired",
          "count": 0
        }
      ],
      "rollupTotal": 1,
      "belowCount": 0,
      "childCount": 0,
      "targets": [],
      "targetCount": 0
    }
  ],
  "advisories": [],
  "slices": [
    {
      "id": "package:acme::shop",
      "kind": "package",
      "anchor": "acme::shop",
      "nodes": [
        "acme::shop::Address",
        "acme::shop::Addressable",
        "acme::shop::AuditEntry",
        "acme::shop::BaseEntity",
        "acme::shop::Customer",
        "acme::shop::Order",
        "acme::shop::OrderNote",
        "acme::shop::OrderNotePrompt",
        "acme::shop::OrderNoteRequest",
        "acme::shop::Shop"
      ]
    },
    {
      "id": "prompt:acme::shop::OrderNotePrompt",
      "kind": "prompt",
      "anchor": "acme::shop::OrderNotePrompt",
      "nodes": [
        "acme::shop::OrderNote",
        "acme::shop::OrderNotePrompt",
        "acme::shop::OrderNoteRequest"
      ]
    },
    {
      "id": "requirement:acme::shop::Shop",
      "kind": "requirement",
      "anchor": "acme::shop::Shop",
      "nodes": [
        "acme::shop::Customer",
        "acme::shop::Order",
        "acme::shop::Order.reference",
        "acme::shop::OrderNotePrompt",
        "acme::shop::Shop",
        "acme::shop::Shop.Checkout",
        "acme::shop::Shop.Checkout.Orders",
        "acme::shop::Shop.Checkout.Orders.Noted",
        "acme::shop::Shop.Checkout.Orders.Recorded",
        "acme::shop::Shop.Checkout.Orders.Recorded.Quotable",
        "acme::shop::Shop.Checkout.Orders.Refunded",
        "acme::shop::Shop.Checkout.Shipping"
      ]
    },
    {
      "id": "requirement:acme::shop::Shop.Checkout",
      "kind": "requirement",
      "anchor": "acme::shop::Shop.Checkout",
      "nodes": [
        "acme::shop::Customer",
        "acme::shop::Order",
        "acme::shop::Order.reference",
        "acme::shop::OrderNotePrompt",
        "acme::shop::Shop.Checkout",
        "acme::shop::Shop.Checkout.Orders",
        "acme::shop::Shop.Checkout.Orders.Noted",
        "acme::shop::Shop.Checkout.Orders.Recorded",
        "acme::shop::Shop.Checkout.Orders.Recorded.Quotable",
        "acme::shop::Shop.Checkout.Orders.Refunded",
        "acme::shop::Shop.Checkout.Shipping"
      ]
    },
    {
      "id": "requirement:acme::shop::Shop.Checkout.Orders",
      "kind": "requirement",
      "anchor": "acme::shop::Shop.Checkout.Orders",
      "nodes": [
        "acme::shop::Customer",
        "acme::shop::Order",
        "acme::shop::Order.reference",
        "acme::shop::OrderNotePrompt",
        "acme::shop::Shop.Checkout.Orders",
        "acme::shop::Shop.Checkout.Orders.Noted",
        "acme::shop::Shop.Checkout.Orders.Recorded",
        "acme::shop::Shop.Checkout.Orders.Recorded.Quotable",
        "acme::shop::Shop.Checkout.Orders.Refunded"
      ]
    },
    {
      "id": "requirement:acme::shop::Shop.Checkout.Orders.Recorded",
      "kind": "requirement",
      "anchor": "acme::shop::Shop.Checkout.Orders.Recorded",
      "nodes": [
        "acme::shop::Customer",
        "acme::shop::Order",
        "acme::shop::Order.reference",
        "acme::shop::Shop.Checkout.Orders.Recorded",
        "acme::shop::Shop.Checkout.Orders.Recorded.Quotable"
      ]
    }
  ]
}

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • 🚨 server/python/src/metaobjects/codegen/generators/docs_site_generator.py:199 - Python verify --codegen does not render what gen wrote for docs-site, so a fresh metaobjects gen followed by metaobjects verify --codegen reports drift. The CLI's in-memory verify render calls _run_gen_targets with no project_root and no gen_state_dir (cli.py:2649 and 2659). gen passes both (cli.py:2210-2213). For docs-site this has five effects. (1) known is False, so the title is "Metadata" instead of the project directory's name, and explorer-model.js and explorer-stamp.js differ on every project that sets no title. (2) runner.py _manifest_key (line 78) keys emitted files relative to the virtual out_dir (models/x.py), while gen keys them relative to the project (gen/models/x.py). The explorer.json files paths therefore differ. (3) With gen_state_dir None, _run_provenance carries no manifest entries, so files from other targets or generators that gen listed are missing. (4) The owned theme and templates under codegen/docs-site/ are skipped (lines 212-213) and templates/ is not searched for prompts (line 247). (5) verifyFile and routesFile resolve against the process cwd instead of the project. The C# port fixes this with CodegenRunner.CaptureKeys (CodegenDrift.cs:151), which keys captured files by the real output directory and reads the real manifest. The intent states this as a decision ("in the drift gate (capture mode) files are keyed by the real output directory so verify --codegen renders what gen wrote"), and the changelog claims it for both ports. Sibling defect in the same path: in a multi-target Python project, every target runs its own run_gen and the shared session saves the manifest only after the whole plan (cli.py ~1856). _run_provenance reads the manifest from disk (_read_union), so a docs-site in target B does not see the files target A wrote in this run. Two identical gen runs on a fresh project then write different explorer.json files. The fix: give the verify render the real project root, gen-state dir and real-out-dir keying (the Python equivalent of CaptureKeys), and read carried provenance from the in-memory session (config.manifest) instead of disk. Add a Python test that runs gen and then verify --codegen with docs-site plus another generator, as C#'s The_drift_gate_renders_what_gen_wrote does.
  • ⚠️ server/csharp/MetaObjects.Codegen/CodegenRunner.cs:174 - CarriedFiles builds the run's suite from g.Name (entity-generator, routes-generator, filter-allowlist-generator, ...). The manifest's generatedBy is now the stable name (entity, routes, filter-allowlist; line 196 and line 223). !suite.Contains(prov.GeneratedBy) is therefore true for every file from those generators, even when they are in this run. The intent's rule is "Committed-manifest provenance is carried for generators not in this run", and that rule fails here. Effect: a file that a run generator no longer emits stays in explorer.json, because this run's entries overwrite only the keys they share. Concrete sequence: change an entity's output path or a generator's OutDir, then run dotnet meta gen. The orphan sweep deletes the old files and drops their manifest entries, but the docs site written in that run still lists the old paths under the object. The next dotnet meta verify --codegen carries from the pruned manifest and reports explorer.json as drift. Python does this correctly (runner.py:256, _stable_name(g.name)). Fix: generators.Select(GeneratorRegistry.StableNameOf).
  • ℹ️ server/python/tests/test_meta_endpoint.py - In test_docs_etag_and_if_none_match, the assertion meta_docs_etag("\u{0001}f600") == meta_docs_etag("😀".encode("utf-16", "surrogatepass").decode("utf-16")) compares the function with itself on the same string, because the encode/decode round-trip returns the input. It has no independent oracle and would still pass if Python hashed code points instead of UTF-16 code units, which would give a different ETag from the other ports. Replace it with the cross-port values C# pins from TypeScript and Java (MetaEndpointTests: "hello" gives "5-4f9f2cab", "héllo ✓" gives "7-0579d2da"), plus a pinned value for a surrogate-pair string taken from the TypeScript metaDocsEtag.

🔧 Fix applied.
1 error still open:

  • 🚨 server/python/src/metaobjects/cli.py:1886 - Round 1's fix (py-verify-codegen-docs-site-drift) closed the gen/verify mismatch only when the docs-site target is declared AFTER the code targets. It left two sibling paths in place. The Python runner runs a reads_run_output generator last only inside one run_gen call (runner.py:244). _run_plan (cli.py:1886) still runs targets in declared order. A docs-site target therefore sees only what earlier targets wrote this run, plus the manifest as committed BEFORE this run (HashManifest.recorded_provenance, overwrite_policy.py:488). verify --codegen has no session, so it reads the manifest from disk as gen left it (runner.py:103).

(1) Docs target declared first. Use targets: {docs: {outDir: docs, generators: [docs-site]}, app: {outDir: gen, generators: [entity]}} on a fresh project. The first gen runs docs before app, so explorer.json lists no entity files. Then app writes gen/... and saves provenance. verify --codegen --full reads that manifest from disk and lists the entity files, so it reports explorer.json as drift. A second gen --force writes a different explorer.json. Round 1 used exactly this symptom ("two identical gen runs on a fresh project then write different explorer.json"). The intent requires that the runner lists the run's files "whatever the declared order".

(2) Docs target declared after the code target, and a code-target generator stops emitting a file for a node that still exists (for example, the app target's outputLayout changes). The session still holds the old committed entry, because the orphan sweep runs only after the whole plan (cli.py:2236). The entry is carried because its generator is not in the docs target's suite, so gen lists the deleted path. verify then reads the swept manifest and reports drift. The ADR-0064 skip can also keep the next plain gen from repairing explorer.json.

The new parametrized test (test_docs_site_generator.py:153) covers only app-before-docs with no removed files, so it passes with both paths broken.

Fix at the plan level: run every target whose suite holds a reads_run_output generator after all other targets. Also exclude committed entries from generators that already ran in this plan unless this run re-noted them. Verify must apply the same rule, so give it an equivalent in-memory record of the captured provenance from earlier targets. Add docs-first and removed-file cases to the parametrized test.

🔧 Fix applied.
1 error still open:

  • 🚨 server/python/src/metaobjects/codegen/runner.py:102 - The docs site still lists files that the same run deletes. Round 2 (py-cross-target-docs-site-order) chose which committed files to carry by generator name: prov[0] not in ran. It did not use the orphan sweep's scope, so a sibling of round 2's path (2) remains.

Path A, a generator removed from the list. This is routine. Remove queries from a target's generators and run gen. queries ran nowhere in the plan, so _run_provenance carries every committed queries entry, and docs-site writes explorer.json listing those paths. The orphan sweep runs after the whole plan (cli.py _sweep_orphans_after_gen). It deletes those files and drops their manifest entries.

verify --codegen --full then reads the swept manifest, does not list the files, and reports explorer.json as drift. CI runs --full and goes red. The local ADR-0064 skip may also answer "in sync" and keep the next plain gen from repairing the file.

C# has the same defect: CodegenRunner.cs:262 CarriedFiles carries !suite.Contains(prov.GeneratedBy), and the sweep at CodegenRunner.cs:~226 runs after docs-site in the same Run.

Path B, the same generator in two targets (Python only). Use app1 {outDir gen1, [entity, docs-site], entities [A]} and app2 {outDir gen2, [entity], entities [B]}. gen --target app1 treats entity as ran. Every committed entity entry is excluded, including app2's gen2 files, which this run neither renders nor sweeps. explorer.json loses B's files until a full gen, and a full verify --codegen reports drift in the meantime.

Remedy: carry a committed entry only when this run's orphan sweep leaves it alone. That means the entry lies outside every outDir the run sweeps, or --entities narrows the run. Java does this (committedFilesBeside / OrphanSweep.isCandidate, commit 7a75c99). Entries inside a swept outDir are either re-emitted, and so already in plan.files or emitted, or about to be deleted. Apply the rule in Python _run_provenance (runner.py:99-104), which gen and verify share, and in C# CarriedFiles (CodegenRunner.cs:257-264).

Add a removed-generator case to test_docs_site_generator.py's parametrized drift test and a C# counterpart. Each runs gen with [entity, queries, docs-site], drops queries, runs gen again, then asserts every listed path exists and that verify --codegen --full is clean. The current removed-file case passes only because entity still runs.

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ⚠️ server/python/src/metaobjects/codegen/generators/docs_site_generator.py:215 - DocsSiteGenerator._provenance tests if ctx.run_provenance:. An empty dict is falsy, so the method falls back to reading the whole committed manifest with no filter. Round 3 (carry-deleted-orphans) made an empty list a normal result: _run_provenance now drops every committed entry inside the sweep scope, which can leave nothing. Round 3 moved the 'never list a file the run removes' defect here and left this sibling in place.

Concrete sequence:

  1. Use one target {outDir gen, generators [entity, docs-site]} and run gen. The manifest records gen/... entity files with their source nodes.
  2. Change the target to [docs-site] and run gen. Nothing else is emitted, and every committed gen/ entry is in the sweep scope and excluded, so run_provenance == {}.
  3. _provenance reads the raw manifest and lists the entity files in explorer.json.
  4. _sweep_orphans_after_gen deletes those entity files and their manifest entries.
  5. verify --codegen --full reads the swept manifest, also gets {}, falls back to it, lists nothing, and reports explorer.json as drift. The site also names files that no longer exist.

C# does not have this bug: ctx.GeneratedFiles ?? manifest falls back only on null (DocsSiteGenerator.cs:69-70).

Fix: change the test to if ctx.run_provenance is not None:. Keep the manifest fallback only for a caller outside a run (None). Update the docstring, which still says 'with an empty list ... what the committed hash manifest records'. Add a case to test_the_drift_gate_renders_what_gen_wrote: [entity, docs-site] then [docs-site]. Assert that every listed path exists and that verify --codegen --full exits 0. The oracle is the existence of the files on disk after the sweep. The current code fails that check.

  • ℹ️ docs/ports/csharp.md:1293 - Applied inline. Three docs still described the round-2 carry rule: committed provenance carried 'for generators the run does not include'. Round 3 replaced it with 'outside the directories the run's orphan sweep clears'. I reworded docs/ports/csharp.md:1293, docs/features/explorer-site.md:76 and changelog.d/explorer-csharp-python.md:7-8 to match the code (CarriedFiles / _run_provenance using OrphanSweep.InScope / in_sweep_scope).

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ℹ️ docs/ports/csharp.md:1293 - Applied inline. Three docs still described the round-2 carry rule: committed provenance carried 'for generators the run does not include'. Round 3 replaced it with 'outside the directories the run's orphan sweep clears'. I reworded docs/ports/csharp.md:1293, docs/features/explorer-site.md:76 and changelog.d/explorer-csharp-python.md:7-8 to match the code (CarriedFiles / _run_provenance using OrphanSweep.InScope / in_sweep_scope).
  • ⚠️ server/csharp/MetaObjects.Codegen/Generators/DocsSiteGenerator.cs:69 - Round 5 (py-empty-run-provenance) went beyond the driver instruction and made the C# and Python ports disagree with the TypeScript reference. Both ports now return no file list (sources.files: false) whenever the run's file list is empty, even when a committed manifest exists. The instruction asked for that only when the list is empty AND the project has no committed manifest.

The reference treats an empty run differently. In TypeScript, runDocsView (server/typescript/packages/codegen-ts/src/docs-view-run.ts:37-56) passes manifest: {} whenever runOutput is defined, so sources.files is true. Java does the same: runFiles != null ? provenanceJson(runFiles) (DocsSiteGenerator.java:102-104), and Kotlin uses Java's generator.

Concrete sequence: run gen with [entity, docs-site], then run gen with [docs-site]. TS, Java and Kotlin write sources.files: true and list no files, so the explorer says "Nothing generated is traced to it." C# and Python write sources.files: false, so the explorer says "No generation manifest was read." That label is wrong, because the run's output was read.

Round 5 also broke C#, which was correct before: ctx.GeneratedFiles ?? manifest already kept an empty list. Round 4's finding said so explicitly ("C# does not have this bug").

The new tests assert the diverging value. They copy the implementation's rule and have no independent oracle:

  • DocsSiteGeneratorTests.cs:126-139 A_site_generated_alone_lists_no_files_and_says_so asserts files is False.
  • test_docs_site_generator.py:169 and :207-208, the docs-alone case, asserts view["sources"]["files"] is False.

Other sites that must hold the same rule:

  • server/python/src/metaobjects/codegen/generators/docs_site_generator.py:227-229 (if not ctx.run_provenance: return None) and its docstring at :222-225.
  • C# CodegenDrift / CaptureKeys, which reuses the generator, so it follows automatically.

The Python corpus harness _run (test_docs_site_generator.py:94-110) explains why the exception exists. It drives the crm and model-alone cases through run_gen, and those cases expect files: false. Under TypeScript semantics, a run is never 'no manifest read'.

Fix:

  1. In a run, use the run's list even when it is empty, in both ports. That matches TypeScript and Java.
  2. Keep the committed-manifest fallback only outside a run (null/None).
  3. Make the Python byte-for-byte corpus test call the generator outside a run (run_provenance None), the way Java's corpus test and C#'s Conformance test reach the builder.
  4. Change both new tests to expect files: true with nothing listed. The oracle is TypeScript's runDocsView for the same project.

The [entity, docs-site] then [docs-site] drift case stays clean under this fix, because gen and verify share the rule.

🔧 Fix applied.
📝 1 wording or comment-placement note left for the author (no fix round spent):

  • ℹ️ docs/ports/csharp.md:1293 - Applied inline. Three docs still described the round-2 carry rule: committed provenance carried 'for generators the run does not include'. Round 3 replaced it with 'outside the directories the run's orphan sweep clears'. I reworded docs/ports/csharp.md:1293, docs/features/explorer-site.md:76 and changelog.d/explorer-csharp-python.md:7-8 to match the code (CarriedFiles / _run_provenance using OrphanSweep.InScope / in_sweep_scope).
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Python: metaobjects gen with a docs-site target writes explorer.json and site files; fresh verify --codegen --full is in sync (shop model, local CLI) ✅ pass live Python gen exit 0 (17 files); verify exit 0 '[docs]: in sync (9 file(s))'; explorer.json parses with 10 nodes; py-explorer.json artifact
Python: hand-edited explorer.json is refused by gen and flagged as drift by verify ✅ pass live gen: 'Refused to overwrite site/explorer.json'; verify exit 1 '[docs] generated code is out of sync with metadata'
C#: dotnet gen with a docs-site entry writes explorer.json; fresh verify --codegen --full is in sync (local CLI, in-repo codegen project) ✅ pass live cs-gen-fresh.txt (gen exit 0, 17 files written incl. docs/site/explorer.json); cs-verify-fresh.txt (verify exit 0)
C#: hand-edited explorer.json is refused by gen and flagged by verify ✅ pass live cs-gen-after-tamper.txt ('refused: docs/site/explorer.json', exit 1); cs-verify-after-tamper.txt ('~ docs/site/explorer.json ... differs', exit 1)
Byte-identical explorer.json for every fixtures/explorer-conformance case across C#, Python and TypeScript, served beside /_meta with ETag/304 ⏸️ untested no Tried live: comparing the C# and Python project outputs. Those differ only in per-language file names, so they are not a byte-identity oracle. The corpus expected.json is pinned by the baseline's port…
  • scripts/ci-local.sh --affected --strict-toolchains
  • Baseline: scripts/ci-local.sh --affected --strict-toolchains (already passed at target commit; not re-run)
  • Python: scratch project copied from fixtures/explorer-conformance/shop/project/metaobjects with targets app[entity] + docs[docs-site]; metaobjects gen (exit 0, 17 files), metaobjects verify --codegen --full (exit 0, docs in sync 9 files)
  • Python: appended line to docs/site/explorer.json; metaobjects gen refused it (exit 1, 'Refused to overwrite site/explorer.json'); metaobjects verify --codegen --full exit 1 with '[docs] generated code is out of sync'
  • C#: dotnet build of server/csharp/MetaObjects.Cli (exit 0); scratch codegen project scaffolded by dotnet MetaObjects.Cli.dll init, pointed at in-repo server/csharp/MetaObjects.Codegen via ProjectReference, with DocsSiteGenerator { OutDir = "docs" } and EntityGenerator added; dotnet run --project codegen -- gen metaobjects --out generated (exit 0, 17 files); verify ... --codegen --full exit 0
  • C#: appended line to docs/site/explorer.json; gen exit 1 with 'refused: docs/site/explorer.json'; verify exit 1 with '~ docs/site/explorer.json (committed content differs from a fresh regen)'
  • Compared C# and Python explorer.json from their own projects: differences limited to per-language entity file names and generatedBy entries; not a byte-identity oracle, so not used as a pass
  • Scratch projects under $DEV_SCRATCH removed; worktree git status clean
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…nd Python manifests

After a write run, the hash manifest entry of a per-object file now names its
generator and the node's resolution key ({hash, generatedBy, sourceNode}, after
the JVM's generator/outputDir), as TypeScript already did, so a docs view built
from any of these ports lists each node's generated files. A whole-model file
keeps the plain hash. A shared 'provenance' vector in
fixtures/codegen-skip-conformance/manifests.json holds TypeScript, C#, Java and
Python to the same entries.
…VM, with no Node

The JVM builds the port-neutral docs view from its loaded model (DocsView), byte for byte
what TypeScript builds for every fixtures/explorer-conformance case, gated in the metadata
suite. A docs-site generator (DocsSiteGenerator, registered in the Java and Kotlin
registries, eject-exempt like TypeScript's) writes explorer.json, the shared explorer app,
explorer-model.js and explorer-stamp.js, and lists each node's generated files from the
hash manifest's provenance. Kotlin runs the same class, and its suite gates every corpus
case through its own registry. MetaEndpoint gains the /_meta/docs helpers (body, ETag,
If-None-Match), mounted by the host as /_meta is.

Needs the HashManifest.loadProvenance API from #669.
…fm/mo-130-docs-view-jvm

# Conflicts:
#	docs/features/explorer-site.md
…h dry-run

cargo publish --workspace unpacks its overlay-registry dependencies into a
per-checkout directory and never re-unpacks while the version is unchanged,
so the self-hosted runner verified metaobjects-codegen against a
metaobjects-1.3.0 unpacked before metamodel_docs existed. Main has been red on
the rust lane since #670 for this reason; the crate itself packages correctly.
…t, and hold docs-site to the inert line

The model and stamp scripts move beside the docs view serializer
(com.metaobjects.docsview.ExplorerModelScript), so codegen-base types no line
breaks (LayoutRatchetTest). The codegen-noop inert tests hold docs-site to the
line TypeScript's rules-inert test draws: the explorer documents every node, so
only its data payload may differ, and only by the new nodes and members.
Each port builds the port-neutral docs view from its loaded model
(MetaObjects.DocsView, metaobjects.docs_view), byte-identical to TypeScript
for every fixtures/explorer-conformance case and gated in each suite. A
docs-site generator in both registries writes explorer.json, the shared
explorer app, explorer-model.js and explorer-stamp.js; it runs after every
other generator and lists this run's files over the committed manifest's,
so verify --codegen renders what gen wrote. MetaEndpoint.MetaDocs (C#) and
meta_docs (Python) serve the same view at /_meta/docs with a strong ETag.
C# and Python provenance now records the generator's registry name.
…s-py

# Conflicts:
#	docs/features/explorer-data.md
#	docs/features/explorer-site.md
#	docs/features/metadata-api.md
#	fixtures/generator-registry-conformance/registry.json
#	server/csharp/MetaObjects.Codegen.Tests/HashManifestPerPackageTests.cs
#	server/csharp/MetaObjects.Codegen/CodegenRunner.cs
#	server/csharp/MetaObjects.Codegen/HashManifest.cs
#	server/python/src/metaobjects/codegen/runner.py
#	server/python/tests/codegen/test_manifest_store.py
@dmealing
dmealing merged commit 50687f0 into main Nov 28, 2026
11 checks passed
@dmealing
dmealing deleted the fm/mo-130-docs-view-cs-py branch November 28, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant